package io.renren.modules.alarm.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.alarm.entity.AreaalarmEntity;
import io.renren.modules.alarm.service.AreaalarmService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2022-08-04 14:20:26
 */
@RestController
@RequestMapping("alarm/areaalarm")
public class AreaalarmController {
    @Autowired
    private AreaalarmService areaalarmService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("alarm:areaalarm:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = areaalarmService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{areaalarmNo}")
    @RequiresPermissions("alarm:areaalarm:info")
    public R info(@PathVariable("areaalarmNo") Integer areaalarmNo){
		AreaalarmEntity areaalarm = areaalarmService.getById(areaalarmNo);

        return R.ok().put("areaalarm", areaalarm);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("alarm:areaalarm:save")
    public R save(@RequestBody AreaalarmEntity areaalarm){
		areaalarmService.save(areaalarm);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("alarm:areaalarm:update")
    public R update(@RequestBody AreaalarmEntity areaalarm){
		areaalarmService.updateById(areaalarm);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("alarm:areaalarm:delete")
    public R delete(@RequestBody Integer[] areaalarmNos){
		areaalarmService.removeByIds(Arrays.asList(areaalarmNos));

        return R.ok();
    }

}
